<?php

namespace common\components;

use kartik\tree\controllers\NodeController;
use yii\helpers\ArrayHelper;

/**
 * 继承原有的Node控制器,实现一些配置的额外处理
 *
 * @package common\components
 */
class TreeNodeController extends NodeController
{

    /**
     * @var array 默认覆盖POST的方法
     */
    public $defaultPostData = [
        'nodeView' => '@common/views/widgets/tree-manager/_node',
    ];

    /**
     * {@inheritdoc}
     */
    public function beforeAction($action)
    {
        if ( ! empty($_POST))
        {
            $_POST = ArrayHelper::merge($_POST, $this->defaultPostData);
        }
        return parent::beforeAction($action);
    }
}
